<?php
/**
 * Created By base
 * Author: Virus
 * Date: 2020/3/12
 * Time: 16:36
 */

namespace app\admin\logic;


use app\common\model\mysql\AuthGroup;

class RoleLogic extends BaseLogic
{
    protected $model = null;

    public function __construct()
    {
        $this->model = new AuthGroup();
    }

    public function saveData($data)
    {
        $data['rules'] = implode(',', $data['rules']);
        $res           = $this->model->saveData($data);
        if ($res === false) {
            throw new \think\Exception("添加失败");
        }

        return true;
    }

    public function updateById($id, $data)
    {
        $res = $this->model->updateById($id, $data);
        if (false === $res) {
            throw new \think\Exception("编辑失败");
        }

        return true;
    }

    public function deleteById($id)
    {
        $res = $this->model->deleteById($id);
        if (false === $res) {
            throw new \think\Exception("角色删除失败");
        }

        return true;
    }
}